Environment

The Environment primitives allow you to obtain information about the Macintosh hardware and software configuration in which the application is running. Use these primitives to test whether certain system features are present before attempting to execute code which may be incompatible with some configurations.

The trap? primitive is used to discover whether certain Macintosh toolbox calls are available on the current hardware and software configuration. Toolbox and Operating System routines on the Macintosh are referred to by a trap number, which is an index into the trap dispatch table which contains the actual addresses of the routines in ROM or the System file. The trap numbers corresponding to a particular toolbox call names are listed in tables in Inside Macintosh. 

There are several ways to check availability of a particular trap. You can call the Gestalt function to see if the appropriate version of the corresponding driver or manager is available. However, if the trap to be tested is not included in any particular manager, and there is no Gestalt selector code for that manager, or if you want to test for the availability of Gestalt itself, the trap? primitive is provided for testing the availability of a trap directly.

_________________________________________________
                          gestalt
 *267*

Input types: integer

Output types: integer

Description: Gestalt Selectors and Responses are documented in Inside Macintosh. If the toolbox call Gestalt is available on the system:
  
 the gestalt primitive calls Gestalt and returns the result; otherwise, gestalt simulates Gestalt for certain selectors by calling GetSysEnv. Response is a 4-byte integer which must be interpreted in different ways depending on the Selector. If Gestalt is not available on the system, and the requested information cannot be simulated with GetSysEnv, Response is 16#80000000.

See also: gestalt-attribute?

_________________________________________________
 
                                                    gestalt-attribute?
*268*

Input types: integer; integer

Output types: [ boolean ]

Description: Some Gestalt selectors return a value with bits set corresponding to what are known as attributes of that selector. This primitive tests the result of calling the toolbox routine Gestalt, and returns TRUE if the given Attribute is set; FALSE otherwise. To learn more about Gestalt Selectors, Attributes and Responses, see Inside Macintosh.

See also: gestalt

_________________________________________________
 
                                          trap?
 *268*

Input types: integer

Output types: [ boolean ]

Description: Result is TRUE if the specified trap is implemented on the current configuration.